#include <iostream>
#include <vector>
#include <string>
#include <cctype>
using namespace std;
void example_p95();
void example_p97();
void example_p98();
void practice_3_21();
void practice_3_22();
void practice_3_23();
void practice_3_24a();
void practice_3_24b();
void practice_3_25();
void practice_3_26();
int main()
{
	example_p98();
	//practice_3_21();
	//practice_3_22();
	//practice_3_23();
	//practice_3_24a();
	//practice_3_24b();
	//practice_3_25();
	//example_p95();
	return 0;
}
void example_p95()
{
	vector<int> v{1,3,5,7,9};
	for(auto it=v.begin();it!=v.end();++it)
	{
		cout<<*it<<endl;
		v.push_back(4);
	}
}
void example_p97()
{
	string s("some string");
	if(s.begin()!=s.end())
	{
		//string::const_iterator it=s.begin();
		//*it=toupper(*it);
	}
}
void example_p98()
{
	const vector<int> cv{3,5,8,7};
	vector<int> v2{4,0,8,9};
	//cv=v2;
	v2=cv;
	for(auto it=v2.begin();it!=v2.end();++it)
		cout<<*it<<" ";
	cout<<endl;
	/**for(auto it=cv.begin();it!=cv.begin();++it)
	{
		if((*it)==8)
			*it=9;
	}
	cv[2]=9;
	
	for(auto s:cv)
		cout<<s<<" ";**/
}
void practice_3_21()
{
	void vec_printer(vector<int> v,int index);
	void vec_printer(vector<string> v,int index);
	vector<int> v1;
	vec_printer(v1,1);
	vector<int> v2(10);
	vec_printer(v2,2);
	vector<int> v3(10,42);
	vec_printer(v3,3);
	vector<int> v4{10};
	vec_printer(v4,4);
	vector<int> v5{10,42};
	vec_printer(v5,5);
	vector<string> v6{10};
	vec_printer(v6,6);
	vector<string> v7{10,"hi"};
	vec_printer(v7,7);
}
void vec_printer(vector<int> v,int index)
{
	cout<<"v"<<index<<":"<<v.size()<<endl;
	for(auto it=v.cbegin();it!=v.cend();++it)
		cout<<*it<<" ";
	cout<<endl;
}

void vec_printer(vector<string> v,int index)
{
	cout<<"v"<<index<<":"<<v.size()<<endl;
	for(auto it=v.cbegin();it!=v.cend();++it)
		cout<<*it<<" ";
	cout<<endl;
}

void practice_3_22()
{
	string text("hehehehehehehheeheheheh ");
	for(auto it=text.begin();it!=text.end()&&!isspace(*it);++it)
		*it=toupper(*it);
	cout<<text<<endl;
}

void practice_3_23()
{
	vector<int> v={1,2,3,4,5,6,7,8,9,10};
	for(auto it=v.begin();it!=v.end();++it)
		*it=*it*2;
	for(auto c:v)
		cout<<c<<" ";
	cout<<endl;
}
void practice_3_24a()
{
	int item;
	vector<int> v;
	while(cin>>item)
		v.push_back(item);
	cout<<"before: "<<endl;
	for(auto c:v)
		cout<<c<<" ";
	cout<<endl;
	cout<<"after:"<<endl;
	for(auto it=v.begin();(v.end()-it)>0;it+=2)//这里如果再it!=v.end()的话+2了之后也！=v.end()，但是指向了未定义的值
	{
		if((it+1)!=v.end())
			cout<<*it+*(it+1)<<" ";
		else
			cout<<*it<<" ";
	}
	cout<<endl;
}
void practice_3_24b()
{
	int item;
	vector<int> v;
	while(cin>>item)
		v.push_back(item);
	cout<<"before: "<<endl;
	for(auto c:v)
		cout<<c<<" ";
	cout<<endl;
	cout<<"after:"<<endl;
	auto beg=v.begin();
	auto end=v.end()-1;
	while(beg<end)
	{
		cout<<*beg+*end<<" ";
		beg++;
		end--;
	}
	if(beg==end)
		cout<<*beg<<" ";
	cout<<endl;
}
void practice_3_25()
{
	vector<unsigned> scores(11,0);
	unsigned grade;
	auto beg=scores.begin();
	while(cin>>grade)
	{
		if(grade<=100)
			++(*(beg+(grade/10)));
	}
	for(auto c:scores)
		cout<<c<<" ";
	cout<<endl;
}
void practice_3_26()
{
	vector<int> v{1,3,6,8,10,9,11,6,34,7};
	auto beg=v.begin();
	auto end=v.end();
	//auto mid=(beg+end)/2;
}